package widgets
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class PreviewAreaMask extends Sprite
	{
		public function PreviewAreaMask()
		{
			super();
			this.mouseEnabled = false;
		}
		
		private var tl:Shape = new Shape(); //左上
		private var tc:Shape = new Shape(); //上中
		private var tr:Shape = new Shape(); //右上
		private var lm:Shape = new Shape(); //左中
		private var rm:Shape = new Shape(); //右中
		private var bl:Shape = new Shape(); //左下
		private var bc:Shape = new Shape(); //下中
		private var br:Shape = new Shape(); //右下
		private var cc:Shape = new Shape();
		public var _width:Number;
		public var _height:Number;
		/**
		 * TLx:起始点(左上角x) TLy:起始点(左上角y) BRx:结束点(右下角x) BRy:结束点(右下角y) 
		 **/
		public function DrawGraphics(TLx:Number,TLy:Number,BRx:Number,BRy:Number):void
		{	
			DrawRect(tl,0,0,TLx,TLy);
			DrawRect(tc,TLx,0,BRx-TLx,TLy);
			DrawRect(tr,BRx,0,this._width-BRx,TLy);//DrawRect(tr,BRx,0,320-BRx,TLy);
			DrawRect(lm,0,TLy,TLx,BRy -TLy);
			DrawRect(rm,BRx,TLy,this._width-BRx,BRy-TLy);//DrawRect(rm,BRx,TLy,320-BRx,BRy-TLy);
			DrawRect(bl,0,BRy,TLx,this._height-BRy);DrawRect(bl,0,BRy,TLx,240-BRy);
			DrawRect(bc,TLx,BRy,BRx-TLx,this._height-BRy); //DrawRect(bc,TLx,BRy,BRx-TLx,240-BRy);
			DrawRect(br,BRx,BRy,this._width-BRx,this._height-BRy); //DrawRect(br,BRx,BRy,320-BRx,240-BRy);
			DrawFillRect(cc,TLx,TLy,BRx-TLx,BRy-TLy);
		}
		
		private function DrawRect(shape:Shape,x:Number,y:Number,width:Number,height:Number):void
		{
			shape.graphics.clear();
			shape.graphics.lineStyle(0,0,0,true);
			shape.graphics.beginFill(0xeeeeee,0.7);
			shape.graphics.drawRect(x,y,width,height);
			shape.graphics.endFill();
//			var txt:TextField = new TextField();
//			txt.text = shape.name;
//			txt.x = x;
//			txt.y = y;
			//this.addChild(txt);
			this.addChild(shape);
		}
		private function DrawFillRect(shape:Shape,x:Number,y:Number,width:Number,height:Number):void
		{
			shape.graphics.clear();
			shape.graphics.lineStyle(1,0,0.3,true);
			shape.graphics.beginFill(0,0);
			shape.graphics.drawRect(x,y,width,height);
			shape.graphics.endFill();
			this.addChild(shape);
		}
		
	}
}